class Solution {
public:
    int removeDuplicates(vector<int>& nums) {
        int i = 0;
        vector<int> temp;
        while(i<nums.size())
        {
            if(i == nums.size()-1)
            temp.push_back(nums[i]);   
            else if(nums[i] != nums[i+1] && i != nums.size()-1)
            temp.push_back(nums[i]);
     
            i++;
        }
        for(int j = 0;j<temp.size();j++)
        {
            nums[j] = temp[j];
        }
        return temp.size();
    }
};
